<div>
    <h2>Ολοκλήρωση παραγγελίας</h2>
    <table cellpadding="0" cellspacing="0">
        <tr>
            <th>Κατηγορία</th>
            <th>Προϊόν</th>
            <th>Τιμή</th>
            <th>Ποσότητα</th>
            <th>Τελική τιμή</th>
        </tr>
        <?php
        $finalprice = 0;
        $i = 0;
        foreach ($result as $record):
            $class = null;
            if ($i++ % 2 == 0) {
                $class = ' class="altrow"';
            }
        ?>
            <tr<?php echo $class; ?>>
                <td>
                <?php echo $record['category']; ?>
            </td>
            <td>
                <?php echo $this->Html->link($record['name'], '/products/details/' . $record['id'], array()); ?>
            </td>
            <td>
                <?php echo $record['price']; ?>
            </td>
            <td><?php
                echo $record['quantity'];
                ?>
            </td>
            <td><?php
                $fullprice = $record['quantity'] * $record['price'];
                $finalprice = $finalprice + $fullprice;
                echo $fullprice;
                ?>
            </td>
        </tr>
        <?php endforeach; ?>
                <tr>
                    <td colspan="4" style="text-align: right">Σύνολο:</td>
                    <td><?php echo $finalprice ?></td>
                </tr>
            </table>
            <br/>
            <br/>
            <div>
        <?php echo $this->Form->create(); ?>
                <fieldset>
            <?php
                echo $this->Form->input('Order.price', array('type' => 'hidden', 'default' => $finalprice));
                echo $this->Form->input('Order.status_id', array('type' => 'hidden', 'default' => 1));
                echo $this->Form->input('Order.user_id', array('type' => 'hidden', 'default' => $user['User']['id']));
                echo $this->Form->input('Order.address', array('default' => $user['User']['address'],'label' => 'Διεύθυνση'));
                echo $this->Form->input('Order.city', array('default' => $user['User']['city'],'label' => 'Πόλη'));
                echo $this->Form->input('Order.tk', array('default' => $user['User']['tk'],'label' => 'ΤΚ'));
                $i = 0;
                foreach ($result as $record) {
                    echo $this->Form->input('OrderProduct.' . $i . '.product_id', array('type' => 'hidden', 'default' => $record['id']));
                    echo $this->Form->input('OrderProduct.' . $i . '.order_id', array('type' => 'hidden'));
                    echo $this->Form->input('OrderProduct.' . $i . '.quantity', array('type' => 'hidden', 'default' => $record['quantity']));
                    $i++;
                }
            ?>
            </fieldset>
        <?php echo $this->Form->end('Καταχώρηση'); ?>
    </div>
</div>